package com.atguigu.service_edu.controller;


import com.atguigu.commonutils.R;
import com.atguigu.service_edu.entity.subject.OneSubject;
import com.atguigu.service_edu.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author clark
 * @since 2020-04-09
 */
@Api(description = "课程管理")
@CrossOrigin
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    //添加课程分类--通过上传Excel
    @ApiOperation(value = "添加课程分类--通过上传Excel")
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        eduSubjectService.saveSubject(file,eduSubjectService);
        return R.ok();
    }
    @ApiOperation(value = "查找所有课程分类")
    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        //由于一级分类中包含了二级分类,所以List中的泛型采用一级分类即可
        List<OneSubject> list = eduSubjectService.getAllOneTwoSubject();


        return R.ok().data("list",list);
    }

    @ApiOperation(value= "查找出所有一级分类")
    @GetMapping("/getOneSubjectList")
    public R getOneSubjectList(){

        return R.ok();
    }



}

